package cn.mothin.frame.core.base;

import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;

import cn.mothin.frame.core.interfaces.ILoginUser;
import cn.mothin.frame.core.interfaces.ISqlHelper;
import cn.mothin.frame.util.JsonUtil;

public class BaseService {
	@Autowired
	protected ISqlHelper sqlHelper;
	@Autowired
	protected JsonUtil jsonUtil;
	
	protected String toJson(Object obj){
		return jsonUtil.toJson(obj);
	}
	
	protected ILoginUser getLoginUser() {
		Object object = ServletActionContext.getRequest().getSession()
				.getAttribute(BaseAction.LOGIN_SYSTEM_USER_SESSION_ID);
		if (object != null && object instanceof ILoginUser) {
			return (ILoginUser) object;
		}
		return null;
	}
}
